import 'package:flutter/material.dart';

import '../tool/assets.dart';

class kContainer extends StatelessWidget {
  final Widget? child; // 新增的 child 属性
  EdgeInsets padding = EdgeInsets.zero;
  // 构造函数，接受所有 Container 的参数
  kContainer({
    super.key,
    this.child,
    this.padding = EdgeInsets.zero,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
        padding: padding,
        decoration: BoxDecoration(
            color: Color_bg_view,
            borderRadius: BorderRadius.circular(4.0),
            border: Border.all(color: Color_border, width: 1.0)),
        child: child ?? const SizedBox.expand());
  }
}

/// 带主题背景颜色，和边框的视图
class kExpanded extends StatelessWidget {
  int flex = 1;
  final Widget? child; // 新增的 child 属性

  // 构造函数，接受所有 Container 的参数
  kExpanded({
    super.key,
    this.flex = 1,
    this.child,
  });

  @override
  Widget build(BuildContext context) {
    return Expanded(flex: flex, child: kContainer(child: child));
  }
}
